<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 将 obejct 对象中属性是空字符串的替换为 null -->
    <script>
      let obj = {
        name: 'lyy',
        age: ''
      }
      //将js的值转换为json字符串
      let list = JSON.stringify(obj)
      //将空字符串替换为null
      let res = list.replace(/""/g, 'null')
      obj = JSON.parse(res)
      console.log(obj)
    </script>
  </body>
</html>
